<h1>用户注册</h1>

<!--创建用户表单，并跳转至用户注册页面-->
<%= form_with(model: @user, url: signup_path) do |form| %>
  <!-- 展示错误信息 -->
  <% if @user.errors.any? %>
    <div class="alert alert-danger">
      <h4><%= pluralize(@user.errors.count, "error") %> 阻止了注册:</h4>
      <ul>
        <% @user.errors.full_messages.each do |msg| %>
          <li><%= msg %></li>
        <% end %>
      </ul>
    </div>
  <% end %>
  <!--注册用户的表单信息-->
  <div class="form-group">
    <%= form.label :name, "用户名" %>
    <%= form.text_field :name, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :email, "电子邮箱" %>
    <%= form.email_field :email, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :password, "密码" %>
    <%= form.password_field :password, class: "form-control" %>
  </div>

  <div class="form-group">
    <%= form.label :password_confirmation, "确认密码" %>
    <%= form.password_field :password_confirmation, class: "form-control" %>
  </div>

  <%= form.submit "注册", class: "btn btn-primary" %>
<% end %>

<p>已有账号？<%= link_to "立即登录", login_path %></p>
